package com.ruoyi.app.controller

import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.back.domain.ChannelManager
import com.ruoyi.back.service.ChannelManagerService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("api/channel")
@Api(tags = ["渠道相关api"])
class ChannelApiController {

    @Autowired
    private lateinit var channelManagerService: ChannelManagerService

    @ApiOperation("是否收费")
    @GetMapping("booleanToll/{code}")
    fun booleanToll(@PathVariable code: String): Data<Boolean> =
        Ok("获取成功", channelManagerService.getOne(
            KtQueryWrapper(ChannelManager::class.java)
                .eq(ChannelManager::code, code)
        )
            ?.charge ?: true)
}